<template>
	<view >
		<view class="padding-sm bg-orange light">
			<text>{{lang == 'cn' ? '通过贡献名人语录，使用这个APP的人都可以随机的看到这条语录！' : 'Please input your quote for app.'}}</text>
		</view>
		<view class="bg-white margin-top padding-sm">
			<textarea :placeholder="lang == 'cn' ? '请输入名人名言' : 'Please input quote.'" v-model="bean.content"/>
		</view>
		<view class="flex flex-direction padding margin" @click="saveBean">
			<button class="cu-btn bg-gradual-orange lg">{{lang == 'cn' ? '提交保存' : 'Submit now'}}</button>
		</view>
	</view>
</template>

<script>
	
	export default{
		data:function(){
			return{
				lang:uni.getStorageSync('lang'),
				bean:{},
				beanList:[]
			}
		},
		methods:{
			saveBean:function(){
				if(!this.bean.content){
					this.util.toast(this.lang == 'cn' ? '请输入名人名言' : 'Please input quote.');return;
				}
				this.bean.nickname = uni.getStorageSync('user').nickname;
				this.bean.userIcon = uni.getStorageSync('user').icon;
				this.bean.email = uni.getStorageSync('user').email;
				this.bean.userId = uni.getStorageSync('user').id;
				this.bean.lang = uni.getStorageSync('lang');
				if(!uni.getStorageSync('user').id || ! uni.getStorageSync('user').email){
					this.util.toast('请先登录');return;
				}
				uni.request({
					url:this.host + '/today/saveQuote',
					method:'POST',
					header:this.util.header(),
					data:this.bean,
					success: (res) => {
						if(res.data.data.flag == 0){
							setTimeout(()=>{
								this.util.to_back();
							},1500);
						}
						this.util.toast(res.data.data.msg);
					}
				})
			}
		},
		onShow() {
			this.lang = uni.getStorageSync('lang');
		}
	}
</script>

<style>
</style>
